#ifndef _CAR_STORAGE_H_
#define _CAR_STORAGE_H_

typedef short int s16;
typedef struct{
    s16 len; //if had not data = -1,else is the sizeof(lenth)+char[]
    char datas[0];
}storage_t;
#define CN_STORAGE_LENGTH_NONE      (-1)
#define CN_STORAGE_HEAD_LENGTH      (sizeof(storage_t))

typedef struct{
    char *buffer;
    int length;

    //if in==out -> have not used datas!
    int in;
    int out;
    int counts;
    pthread_mutex_t lock;
}storage_buffer_t;

int StorageInit(storage_buffer_t* sto,char* buffer,int buflen);
int StorageClean(storage_buffer_t* sto);
int StorageAddDatas(storage_buffer_t* buf,char* dat,int datalen);
int StorageGetDatas(storage_buffer_t* buf,char* out,int buflen);

#define SMALL_LOCK_EN   1

#endif
